<?php
class CPyramidMemberInv extends Zend_Db_Table
{
	protected $_name = '';
	protected $_primary = '';
	
	public function __construct()
	{
		$this->_name = R_PRE . 'pyramid_member_inv';
		$this->_primary = 'inv_id';
		parent::__construct();
	}
	
	public function add($row, $uid)
	{
		$db = $this->getAdapter();
		$where = $db->quoteInto('uid = ?', $uid);
		$sql = 'select * from ' . $this->_name . ' where ' . $where;
		$result = $db->fetchAll($sql);
		if (count($result) > 0) {
			return $this->update($row, $where);
		}
		
		$row['uid'] = $uid;
				
		return $this->insert($row);
	}
	
	public function del($uid)
	{
		$db = $this->getAdapter();
		$where = $db->quoteInto('uid = ?', $uid);
		return $this->delete($where);
	}
	
	public function getInv($uid)
	{
		return $this->fetchRow(array('uid = ?'=>$uid));
	}
}